/*    */ package com.zimbra.cs.filter;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import org.apache.jsieve.parser.SieveNode;
/*    */ import org.apache.jsieve.parser.generated.Node;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ class FolderRenamer
/*    */   extends SieveVisitor
/*    */ {
/*    */   String mOldPath;
/*    */   String mNewPath;
/* 28 */   boolean mRenamed = false;
/*    */   
/*    */   FolderRenamer(String oldPath, String newPath)
/*    */   {
/* 32 */     this.mOldPath = prefixWithSlash(oldPath);
/* 33 */     this.mNewPath = prefixWithSlash(newPath);
/*    */   }
/*    */   
/*    */   boolean renamed() {
/* 37 */     return this.mRenamed;
/*    */   }
/*    */   
/*    */   protected void visitFileIntoAction(Node node, SieveVisitor.VisitPhase phase, SieveVisitor.RuleProperties props, String folderPath)
/*    */     throws ServiceException
/*    */   {
/* 43 */     if ((phase != SieveVisitor.VisitPhase.begin) || (folderPath == null)) {
/* 44 */       return;
/*    */     }
/* 46 */     folderPath = prefixWithSlash(folderPath);
/* 47 */     if (folderPath.startsWith(this.mOldPath)) {
/* 48 */       String newPath = folderPath.replace(this.mOldPath, this.mNewPath);
/* 49 */       SieveNode folderNameNode = (SieveNode)getNode(node, new int[] { 0, 0, 0, 0 });
/* 50 */       String escapedName = FilterUtil.escape(newPath);
/* 51 */       folderNameNode.setValue(escapedName);
/* 52 */       this.mRenamed = true;
/*    */     }
/*    */   }
/*    */   
/*    */   static String prefixWithSlash(String path) {
/* 57 */     if ((path == null) || (path.length() == 0)) {
/* 58 */       return path;
/*    */     }
/* 60 */     if (path.charAt(0) != '/') {
/* 61 */       return "/" + path;
/*    */     }
/* 63 */     return path;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/filter/FolderRenamer.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */